﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.DirectX;

namespace MultiResolutioning.Structures
{
	/// <summary>
	/// Klasa reprezentuje operacje laczenia.
	/// </summary>
	public class Split
	{
		public int vertexIdToSplit;
		public int v1Id;
		public int v2Id;
		public Vector3 positionV1;
		public Vector3 positionV2;
		public List<int> faceIdsV1;
		public List<int> faceIdsV2;
		public List<FaceSmall> removedData;

		/// <summary>
		/// Inicjalizuje obiekt.
		/// </summary>
		public Split()
		{
			faceIdsV1 = new List<int>();
			faceIdsV2 = new List<int>();
			removedData = new List<FaceSmall>();
		}

		/// <summary>
		/// Inicjalizuje obiekt.
		/// </summary>
		/// <param name="newVertex">Nowy wierzcholek.</param>
		/// <param name="oldVertex1">Stary wierzcholek 1.</param>
		/// <param name="oldVertex2">Stary wierzcholek 2.</param>
		/// <param name="removedData">Usuniete dane trojkatow.</param>
		public Split(Vertex newVertex, Vertex oldVertex1, Vertex oldVertex2, List<FaceSmall> removedData)
		{
			this.vertexIdToSplit = newVertex.vertexId;

			this.v1Id = oldVertex1.vertexId;
			this.v2Id = oldVertex2.vertexId;

			this.positionV1 = new Vector3(oldVertex1.position.X, oldVertex1.position.Y, oldVertex1.position.Z);
			this.positionV2 = new Vector3(oldVertex2.position.X, oldVertex2.position.Y, oldVertex2.position.Z);

			faceIdsV1 = oldVertex1.faces.Select(x => x.faceId).ToList();
			faceIdsV2 = oldVertex2.faces.Select(x => x.faceId).ToList();

			this.removedData = removedData;
		}
	}
}
